package com.sunday.electric.fragment;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.sunday.common.event.EventBus;
import com.sunday.common.qrcode.CaptureActivity;
import com.sunday.electric.R;
import com.sunday.electric.base.BaseFragment;
import com.sunday.electric.ui.mine.NoticeActivity;
import com.sunday.electric.ui.mine.WebViewActivity;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by wang on 2016/3/9.
 */
public class QRCodeFragment extends BaseFragment {
    @Bind(R.id.left_btn)
    ImageView leftBtn;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.fragment_tab_list,null);
        ButterKnife.bind(this,rootView);
        return rootView;
    }


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        leftBtn.setVisibility(View.GONE);
        EventBus.getDefault().register(this);
    }

    @OnClick(R.id.qr_code)
    void qrcode(){
        intent = new Intent(mContext,CaptureActivity.class);
        startActivityForResult(intent,0x111);
    }

    public void onEvent(String str){
        intent = new Intent(mContext, WebViewActivity.class);
        //   intent.putExtra("url",str);
        intent.putExtra("url","http://202.110.130.19:1080/RedAS/app/appPage.go?method=goUcDetailPage");
        startActivity(intent);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode== Activity.RESULT_OK&&requestCode==0x111){
            intent = new Intent(mContext, WebViewActivity.class);
         //   intent.putExtra("url",data.getStringExtra("result"));
            intent.putExtra("url","http://202.110.130.19:1080/RedAS/app/appPage.go?method=goUcDetailPage");
            startActivity(intent);
        }
    }
}
